package com.jm.api.filter;

import com.jm.common.model.StandardSubmit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author:JianWu
 * @Date: 2025/1/9  15:43
 */
@Component
@RefreshScope
public class CheckFilterContext {

    @Value("${filters:api,ip,sign,template,mobile,fee}")
    private String filters;

    @Autowired
    private Map<String,CheckFilter> checkFilterMap;

    public void check(StandardSubmit submit){
        String[] filterArray = filters.split(",");
        for (String filter : filterArray) {
            CheckFilter checkFilter = checkFilterMap.get(filter);
            checkFilter.check(submit);
        }
    }
}
